package com.codefish;

import java.util.Enumeration;
import java.util.Iterator;
import java.util.function.Consumer;

/**
 * 迭代器适配类,适配Enumeration
 *
 * @author codefish
 * @version 1.0
 * @date 2022/06/15 下午 06:38
 */
public class IteratorAdapter<E> implements Iterator<E> {
    Enumeration<E> enumeration;

    public IteratorAdapter(Enumeration<E> enumeration) {
        this.enumeration = enumeration;
    }

    @Override
    public boolean hasNext() {
        return enumeration.hasMoreElements();
    }

    @Override
    public E next() {
        return enumeration.nextElement();
    }
}
